﻿#ifndef VISIONCAMERA_H
#define VISIONCAMERA_H

#include <QObject>

//工作模式
enum WorkMode
{
    FreeAcquire,//自由采集
    SoftTrigger,//软触发
    LineTrigger,//硬触发
    NoKnowWork,//不知道(相机未连接)
};

//本地相机采集模式
enum LocalCameraAcquireMode
{
    NextImage,//下一张图像   条件：相机连接正常; 相机启动正常;
    PrevImage,//上一张图像   条件：相机连接正常; 相机启动正常;
    ForceNext,//强制下一张   条件：相机连接正常;
    ForcePrev,//强制上一张   条件：相机连接正常;
};

//图像
struct FrameInfo
{
    int width;
    int height;
    int color;
    int pixelDigit;
    uchar *data = NULL;
    QString name;//29.bmp图像名称
    QString dataTime;//2019-05-16;16:30:25:666 当前图像生成时间<图像已经传到了PC上>
};

//IO控制线
struct IOLine
{
    bool line0Value;
    bool line2Value;
};

class VisionCamera//:public QObject
{
    //Q_OBJECT
public:
    virtual ~VisionCamera()
    {}

    virtual QString getLastError() = 0;

    //连接
    virtual int connectCamera(QString info) = 0;
    virtual int disConnectCamera() = 0;
    //启动
    virtual int startGrabbing() = 0;
    virtual int stopGrabbing() = 0;

    virtual bool onLineStatus() = 0;
    //图像 - 是否需要队列
    virtual int nextImage(LocalCameraAcquireMode mode = NextImage) = 0;
    virtual int getImage(FrameInfo &info) = 0;

    virtual int getCameraInfo(QString &info) = 0;
    virtual int findCameras(QList<QString> &list) = 0;

    virtual int setWorkMode(WorkMode mode = FreeAcquire, std::string lineName = "Line1") = 0;
    virtual WorkMode getWorkMode() = 0;
    virtual int softTrigger() = 0;

    virtual int setExposureTime(double time,std::string name = "ExposureTime") = 0;
    virtual double getExposureTime(std::string name = "ExposureTime") = 0;

    virtual int setFrameRate(double value) = 0;
    virtual double getFrameRate() = 0;

    virtual int setFrameRateEnable(bool value) = 0;
    virtual int getFrameRateEnable(bool &value) = 0;

    virtual int setReverseX(bool value) = 0;
    virtual int getReverseX(bool &value) = 0;

    virtual int setReverseY(bool value) = 0;
    virtual int getReverseY(bool &value) = 0;

    virtual int getWidth(long long &width) = 0;
    virtual int getHeight(long long &height) = 0;

    virtual int setInputIO(IOLine line,bool value) = 0;
    virtual int setOutputIO(IOLine line) = 0;
};


#endif // VISIONCAMERA_H
